#include "titleform.h"
#include "ui_titleform.h"

#include <QMainWindow>

TitleForm::TitleForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::TitleForm)
{
    ui->setupUi(this);

    ui->toolButton->setIcon(QIcon(":/images/menu.png"));
    //ui->toolButton->setText("菜单");
    ui->toolButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
}

TitleForm::~TitleForm()
{
    delete ui;
}


void TitleForm::on_minBtn_clicked()
{
    QMainWindow *p = dynamic_cast<QMainWindow*>(parent()->parent());
    if(p)
        p->showMinimized();
}

void TitleForm::on_maxBtn_clicked()
{

    QMainWindow *p = dynamic_cast<QMainWindow*>(parent()->parent());
    if(p)
    {
        if(ui->maxBtn->isChecked())
        {
            p->showMaximized();
        }
        else
        {
            p->showNormal();
        }
    }
}

void TitleForm::on_closeBtn_clicked()
{
    QMainWindow *p = dynamic_cast<QMainWindow*>(parent()->parent());
    if(p)
        p->close();
}
